<?php

namespace Home\Controller;

use Faker\Factory;
use Think\Controller;

class FormsController extends Controller
{
    //国内
    public function productCreate()
    {
        $this->display('Forms/product/create');
    }

    public function productShow()
    {
        $this->display('Forms/product/show');
    }

    //International Department国际部
    public function INTProductCreate()
    {
        $this->display('Forms/product/INTCreate');
    }

    public function INTProductShow()
    {
        $this->display('Forms/product/INTShow');
    }


    //客户信息
    public function customersIndex() {
        $faker = Factory::create();
        $lists = [];
        for ($i =0 ;$i < $faker->randomDigit; $i++) {
            $lists[] = [
                'id' => $faker->randomDigit,
                'no' => $faker->numerify('customer###'),
                'customer' => $faker->word,
                'atten' => $faker ->lastName,
                'create_user' => $faker ->lastName,
                'create_time' => $faker ->unixTime,
                'status' => $faker -> numberBetween(1,4)
            ];
        }
        $this->assign('lists', $lists);
        $this->display('Forms/customers/index');
    }

    public function customersCreate() {
        $this->display('Forms/customers/create');
    }

    public function customersEdit() {
        $faker = Factory::create();
        $customer = [
            'no' => $faker->numerify('customer###'),
            'customer' => $faker->word,
            'full_name' => $faker ->name,
            'bill_to' => $faker ->address,
            'ship_to' => $faker ->address,
            'atten' => $faker ->lastName,
            'tel' => $faker ->phoneNumber,
            'fax' => $faker ->phoneNumber,
            'email' => $faker ->regexify('[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,4}'),
            'peyment_term' => $faker ->randomElement(['Wire Transfer', 'Net 15','Net 30', 'Net 45', 'Net 60', 'Net 90', 'L/C']),
            'remark' => $faker->text(200)
        ];

        $this->assign('customer',$customer);
        $this->display('Forms/customers/edit');
    }

    public function customersShow() {
        $faker = Factory::create();
        $customer = [
            'no' => $faker->numerify('customer###'),
            'customer' => $faker->word,
            'full_name' => $faker ->name,
            'bill_to' => $faker ->address,
            'ship_to' => $faker ->address,
            'atten' => $faker ->lastName,
            'tel' => $faker ->phoneNumber,
            'fax' => $faker ->phoneNumber,
            'email' => $faker ->regexify('[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,4}'),
            'peyment_term' => $faker ->randomElement(['Wire Transfer', 'Net 15','Net 30', 'Net 45', 'Net 60', 'Net 90', 'L/C']),
            'remark' => $faker->text(200),
            'status' => $faker->numberBetween(1,4),
            'create_user' => $faker ->lastName,
            'create_time' => $faker ->unixTime,
            'id' => $faker->numerify('customer###')
        ];

        $this->assign('customer',$customer);
        $this->display('Forms/customers/show');
    }
}